package edu.neusoft.springhtmldemo.controller;

import edu.neusoft.springhtmldemo.domain.DatasubStationManagement;
import edu.neusoft.springhtmldemo.service.DatasubStationManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DatasubStationManagementController {
    @Autowired
    private DatasubStationManagementService service;

    @RequestMapping("showDatasubStationManagement")
    public List<DatasubStationManagement> showDatasubStationManagement(){
        List<DatasubStationManagement> lists=service.showAll();
        return lists;
    }

    @RequestMapping("updateDatasubStationManagement")
    public void updateDatasubStationManagement(DatasubStationManagement management){
        service.updateDatasubStation(management);
    }

    @RequestMapping("selectDatasubStationManagement")
    public List<DatasubStationManagement> selectDatasubStationManagement(String datastationID,String datastationName,String datastationIP,String datastationLocation){
        System.out.println(datastationID+"-"+datastationIP+"-"+datastationLocation);
        List<DatasubStationManagement> lists= service.selectDatasubStationManagement(datastationID,datastationName,datastationIP,datastationLocation);
        System.out.println(lists.size());
        for (DatasubStationManagement list : lists) {
            System.out.println(list);
        }
        return lists;
    }

    @RequestMapping("addDatasubStationManagement")
    public void addDatasubStationManagement(DatasubStationManagement management){
        service.addDatasubStationManagement(management);
    }

    @RequestMapping("delDatasubStationManagement")
    public void delDatasubStationManagement(Integer datastationID){
        service.delDatasubStationManagement(datastationID);
    }

    @RequestMapping("datastationIPValues")
    public List<String> datastationIPValues(){
        return service.datastationIPValues();
    }

    @RequestMapping("datastationNameValue")
    public String datastationNameValue(String datastationIP){
        return service.datastationNameValue(datastationIP);
    }
}
